package com.imooc.dto;

import com.fasterxml.jackson.annotation.JsonView;
import com.imooc.validator.MyConstraint;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.security.core.userdetails.UserDetails;

import javax.validation.constraints.Past;
import java.util.Date;

/**
 * Created by zghgchao 2018/4/13 22:45
 * @JsonView的使用
 *      ① 使用接口声明多个视图
 *      ②在值对象的get方法上指定视图
 *      ③在Controller方法上指定视图
 */
public class User {

    /**
     * ①
     */
    public interface UserSimpleView{};
    public interface UserDetailView extends UserSimpleView {};

    private String id;
    @MyConstraint(message = "这是一个测试")
    private String name;
    @NotBlank(message = "密码不能为空")
    private String password;
    @Past(message = "生日必须为过去的时间")
    private Date birthday;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    @JsonView(UserSimpleView.class)
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @JsonView(UserDetailView.class)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
